#pragma once

#include "PlayList.h";

namespace NgheNhac {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::IO;


	/// <summary>
	/// Summary for MyForm
	/// </summary>
	public ref class MyForm : public System::Windows::Forms::Form
	{
	public:
		MyForm(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~MyForm()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	protected:
	private: System::Windows::Forms::ToolStripMenuItem^  songToolStripMenuItem;

	private: System::Windows::Forms::ToolStripMenuItem^  reToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  saveSongToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  playlistToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  createPlaylistToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  savePlaylistToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  removePlaylistToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  helpToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  controlToolStripMenuItem;


	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	private: AxWMPLib::AxWindowsMediaPlayer^  axWindowsMediaPlayer1;


	private: System::Windows::Forms::Button^  btnNext;
	private: System::Windows::Forms::Button^  btnStop;
	private: System::Windows::Forms::Button^  btnBack;

	private: System::Windows::Forms::Button^  btnopen;

	private: System::Windows::Forms::Button^  btnPlay;
	private: System::Windows::Forms::ListBox^  listBox1;
	private: System::Windows::Forms::TextBox^  txtName;

	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TextBox^  txtDate;
	private: System::Windows::Forms::Label^  label2;




	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->songToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->reToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->saveSongToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->playlistToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->createPlaylistToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->savePlaylistToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->removePlaylistToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->controlToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			this->axWindowsMediaPlayer1 = (gcnew AxWMPLib::AxWindowsMediaPlayer());
			this->btnNext = (gcnew System::Windows::Forms::Button());
			this->btnStop = (gcnew System::Windows::Forms::Button());
			this->btnBack = (gcnew System::Windows::Forms::Button());
			this->btnopen = (gcnew System::Windows::Forms::Button());
			this->btnPlay = (gcnew System::Windows::Forms::Button());
			this->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->txtName = (gcnew System::Windows::Forms::TextBox());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->txtDate = (gcnew System::Windows::Forms::TextBox());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->menuStrip1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->axWindowsMediaPlayer1))->BeginInit();
			this->SuspendLayout();
			// 
			// menuStrip1
			// 
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {
				this->songToolStripMenuItem,
					this->playlistToolStripMenuItem, this->helpToolStripMenuItem, this->controlToolStripMenuItem
			});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(649, 24);
			this->menuStrip1->TabIndex = 0;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// songToolStripMenuItem
			// 
			this->songToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
				this->reToolStripMenuItem,
					this->saveSongToolStripMenuItem
			});
			this->songToolStripMenuItem->Name = L"songToolStripMenuItem";
			this->songToolStripMenuItem->Size = System::Drawing::Size(46, 20);
			this->songToolStripMenuItem->Text = L"Song";
			// 
			// reToolStripMenuItem
			// 
			this->reToolStripMenuItem->Name = L"reToolStripMenuItem";
			this->reToolStripMenuItem->Size = System::Drawing::Size(128, 22);
			this->reToolStripMenuItem->Text = L"Remove";
			// 
			// saveSongToolStripMenuItem
			// 
			this->saveSongToolStripMenuItem->Name = L"saveSongToolStripMenuItem";
			this->saveSongToolStripMenuItem->Size = System::Drawing::Size(128, 22);
			this->saveSongToolStripMenuItem->Text = L"Save Song";
			// 
			// playlistToolStripMenuItem
			// 
			this->playlistToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
				this->createPlaylistToolStripMenuItem,
					this->savePlaylistToolStripMenuItem, this->removePlaylistToolStripMenuItem
			});
			this->playlistToolStripMenuItem->Name = L"playlistToolStripMenuItem";
			this->playlistToolStripMenuItem->Size = System::Drawing::Size(56, 20);
			this->playlistToolStripMenuItem->Text = L"Playlist";
			// 
			// createPlaylistToolStripMenuItem
			// 
			this->createPlaylistToolStripMenuItem->Name = L"createPlaylistToolStripMenuItem";
			this->createPlaylistToolStripMenuItem->Size = System::Drawing::Size(157, 22);
			this->createPlaylistToolStripMenuItem->Text = L"Create Playlist";
			// 
			// savePlaylistToolStripMenuItem
			// 
			this->savePlaylistToolStripMenuItem->Name = L"savePlaylistToolStripMenuItem";
			this->savePlaylistToolStripMenuItem->Size = System::Drawing::Size(157, 22);
			this->savePlaylistToolStripMenuItem->Text = L"Save Playlist";
			// 
			// removePlaylistToolStripMenuItem
			// 
			this->removePlaylistToolStripMenuItem->Name = L"removePlaylistToolStripMenuItem";
			this->removePlaylistToolStripMenuItem->Size = System::Drawing::Size(157, 22);
			this->removePlaylistToolStripMenuItem->Text = L"Remove Playlist";
			// 
			// helpToolStripMenuItem
			// 
			this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->exitToolStripMenuItem });
			this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";
			this->helpToolStripMenuItem->Size = System::Drawing::Size(44, 20);
			this->helpToolStripMenuItem->Text = L"Help";
			// 
			// exitToolStripMenuItem
			// 
			this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
			this->exitToolStripMenuItem->Size = System::Drawing::Size(92, 22);
			this->exitToolStripMenuItem->Text = L"Exit";
			this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::exitToolStripMenuItem_Click);
			// 
			// controlToolStripMenuItem
			// 
			this->controlToolStripMenuItem->Name = L"controlToolStripMenuItem";
			this->controlToolStripMenuItem->Size = System::Drawing::Size(59, 20);
			this->controlToolStripMenuItem->Text = L"Control";
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->FileName = L"Music";
			this->openFileDialog1->Filter = L"Mp3|\".mp3|Mp4|\".mp4|Wav|\".wav";
			this->openFileDialog1->Multiselect = true;
			// 
			// axWindowsMediaPlayer1
			// 
			this->axWindowsMediaPlayer1->Enabled = true;
			this->axWindowsMediaPlayer1->Location = System::Drawing::Point(0, 27);
			this->axWindowsMediaPlayer1->Name = L"axWindowsMediaPlayer1";
			this->axWindowsMediaPlayer1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^>(resources->GetObject(L"axWindowsMediaPlayer1.OcxState")));
			this->axWindowsMediaPlayer1->Size = System::Drawing::Size(438, 315);
			this->axWindowsMediaPlayer1->TabIndex = 1;
			// 
			// btnNext
			// 
			this->btnNext->Location = System::Drawing::Point(310, 348);
			this->btnNext->Name = L"btnNext";
			this->btnNext->Size = System::Drawing::Size(75, 23);
			this->btnNext->TabIndex = 4;
			this->btnNext->Text = L"Next";
			this->btnNext->UseVisualStyleBackColor = true;
			// 
			// btnStop
			// 
			this->btnStop->Location = System::Drawing::Point(123, 348);
			this->btnStop->Name = L"btnStop";
			this->btnStop->Size = System::Drawing::Size(75, 23);
			this->btnStop->TabIndex = 5;
			this->btnStop->Text = L"Stop";
			this->btnStop->UseVisualStyleBackColor = true;
			// 
			// btnBack
			// 
			this->btnBack->Location = System::Drawing::Point(216, 348);
			this->btnBack->Name = L"btnBack";
			this->btnBack->Size = System::Drawing::Size(75, 23);
			this->btnBack->TabIndex = 6;
			this->btnBack->Text = L"Back";
			this->btnBack->UseVisualStyleBackColor = true;
			// 
			// btnopen
			// 
			this->btnopen->Location = System::Drawing::Point(21, 348);
			this->btnopen->Name = L"btnopen";
			this->btnopen->Size = System::Drawing::Size(75, 23);
			this->btnopen->TabIndex = 8;
			this->btnopen->Text = L"open";
			this->btnopen->UseVisualStyleBackColor = true;
			this->btnopen->Click += gcnew System::EventHandler(this, &MyForm::btnopen_Click);
			// 
			// btnPlay
			// 
			this->btnPlay->Location = System::Drawing::Point(49, 402);
			this->btnPlay->Name = L"btnPlay";
			this->btnPlay->Size = System::Drawing::Size(75, 23);
			this->btnPlay->TabIndex = 10;
			this->btnPlay->Text = L"Play";
			this->btnPlay->UseVisualStyleBackColor = true;
			this->btnPlay->Click += gcnew System::EventHandler(this, &MyForm::btnPlay_Click);
			// 
			// listBox1
			// 
			this->listBox1->FormattingEnabled = true;
			this->listBox1->Location = System::Drawing::Point(445, 28);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(192, 147);
			this->listBox1->TabIndex = 11;
			// 
			// txtName
			// 
			this->txtName->Location = System::Drawing::Point(537, 181);
			this->txtName->Name = L"txtName";
			this->txtName->Size = System::Drawing::Size(100, 20);
			this->txtName->TabIndex = 12;
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(444, 239);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(75, 23);
			this->button1->TabIndex = 13;
			this->button1->Text = L"Save Playlist";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(445, 187);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(70, 13);
			this->label1->TabIndex = 14;
			this->label1->Text = L"Playlist Name";
			// 
			// txtDate
			// 
			this->txtDate->Location = System::Drawing::Point(537, 207);
			this->txtDate->Name = L"txtDate";
			this->txtDate->Size = System::Drawing::Size(100, 20);
			this->txtDate->TabIndex = 15;
			this->txtDate->Text = L"11/09/2014";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(445, 214);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(70, 13);
			this->label2->TabIndex = 16;
			this->label2->Text = L"Created Date";
			// 
			// MyForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(649, 444);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->txtDate);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->txtName);
			this->Controls->Add(this->listBox1);
			this->Controls->Add(this->btnPlay);
			this->Controls->Add(this->btnopen);
			this->Controls->Add(this->btnBack);
			this->Controls->Add(this->btnStop);
			this->Controls->Add(this->btnNext);
			this->Controls->Add(this->axWindowsMediaPlayer1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->Name = L"MyForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"MyForm";
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->axWindowsMediaPlayer1))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
				 Application::Exit();
	}

	private: System::Void btnopen_Click(System::Object^  sender, System::EventArgs^  e) {
				 OpenFileDialog^ openFiledialog1 = gcnew OpenFileDialog;
				 openFileDialog1->Filter = "Music Files(*.mp3)|*.mp3";
				 openFileDialog1->Multiselect = true;
				 if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK){
					 listBox1->Items->AddRange(openFileDialog1->FileNames);
				 }
	}


	private: System::Void btnPlay_Click(System::Object^  sender, System::EventArgs^  e) {
				 //try{
					// System::Media::SoundPlayer^ player = gcnew System::Media::SoundPlayer();
					// //player->SoundLocation = listBox1->Items->GetEnumerator;
					// player->Load();
					// player->PlaySync();
				 //}
				 //catch (Win32Exception^ ex)
				 //{

					// MessageBox::Show(ex->Message);
				 //}
	}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 // khoi tao doi tuong playlist
			 PlayList^ p = gcnew PlayList(txtName->Text, txtDate->Text);
			 
			 // luu doi tuong playlist vao file text (o cuoi file)
			 String^ filePath = "D:\\playlist.txt";
			 String^ content = p->getName() + "," + p->getCreatedDate() + "-";
			 //FileUtil^ fUtil = gcnew FileUtil();
			 //fUtil->WriteTextFile("C:\\playlist.txt", content);

			 StreamWriter^ sw = gcnew StreamWriter(filePath);
			 sw->WriteLine(content);
			 sw->Close();
			 Console::WriteLine("a new file ('{0}') has been written", filePath);
}
};

}
